package cn.pw.test.com.conversion.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.pw.test.com.conversion.R;

/**
 * 换算公司说明
 */
public class FormulaDirectionsView extends LinearLayout {
    private View mView;

    private TextView termTx;
    private TextView formulaTx;

    public FormulaDirectionsView(Context context) {
        super(context);
        init(context, null);
    }

    public FormulaDirectionsView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public FormulaDirectionsView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        mView = LayoutInflater.from(context)
                .inflate(R.layout.conversion_layout_formula_directions_view, this, true);

        termTx = mView.findViewById(R.id.formula_directions_view_term_tx);
        formulaTx = mView.findViewById(R.id.formula_directions_view_formula_tx);

        if (attrs == null)
            return;
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FormulaDirectionsView);
        String term = ta.getString(R.styleable.FormulaDirectionsView_fdTermText);
        String formula = ta.getString(R.styleable.FormulaDirectionsView_fdFormulaText);

        termTx.setText(term);
        formulaTx.setText(formula);
    }
}
